package com.sinvo.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinvo.oa.entity.model.process.ProcessRecord;
import com.sinvo.oa.entity.model.system.SysUser;
import com.sinvo.oa.mapper.ProcessRecordMapper;
import com.sinvo.oa.service.ProcessRecordService;
import com.sinvo.oa.service.SysUserService;
import com.sinvo.oa.util.LoginUserInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description ProcessRecordService实现类
 */
@Service
public class ProcessRecordServiceImpl extends ServiceImpl<ProcessRecordMapper, ProcessRecord> implements ProcessRecordService {

    @Autowired
    private SysUserService sysUserService;

    @Override
    public void record(Long processId, Integer status, String description) {
        //获取登录用户
        Long userId = LoginUserInfoUtils.getUserId();
        SysUser sysUser = sysUserService.getById(userId);
        //补全数据
        ProcessRecord processRecord = new ProcessRecord();
        processRecord.setProcessId(processId);
        processRecord.setStatus(status);
        processRecord.setDescription(description);
        processRecord.setOperateUser(sysUser.getName());
        processRecord.setOperateUserId(userId);
        this.save(processRecord);
    }
}
